import { View } from "../../../../mvc/core/View";
import { LayerManager } from "../../../manager/LayerManager";
import { Global } from "../../../../../com/gengine/global/Global";
import { ObjCreate } from "../../common/ObjCreate";
import { ToolTipItem } from "../../../../../com/mui/manager/ToolTipItem";
import { GlobalClass } from "../../../../../com/mui/core/GlobalClass";
import { Language } from "../../../../../extend/language/Language";
import { GlobalStyle } from "../../../../common/global/GlobalStyle";
import { SecTimerView } from "../../common/SecTimerView";
import { FilterConst } from "../../../../component/gconst/FilterConst";
import { SGuildTreeRing } from "../../../../../Message/Game/SGuildTreeRing";
import { SceneRange } from "../../../scene/map/SceneRange";
import { TweenMax } from "../../../../../com/greensock/TweenMax";
import { Quint } from "../../../../../com/greensock/easing/Quint";
import { GButton } from "../../../../../com/mui/controls/GButton";
type int = number;
//class GuildTreeFightPanel
    
    export  class GuildTreeFightPanel extends View
    {
        constructor()
        {
            super();
            this.layer = LayerManager.uiLayer;
            this.init();
            this.x = Global.stage.stageWidth - 165;
            this.y = 180 + 20 * Global.stage.stageHeight / 1000;
            return;
        }

        /* internal  */init(): void
        {
            ObjCreate.createBg(0, 0, 140, 120, this);
            this._moveBtn = ObjCreate.createGButton("", 0, 0, 24, 22, this, "MoveBtn");
            this._moveBtn.addEventListener(flash.events.MouseEvent.MOUSE_DOWN, this.onMouseDownHandler);
            this._moveBtn.addEventListener(flash.events.MouseEvent.MOUSE_UP, this.onMouseUpHandler);
            this._showBtn = new ToolTipItem();
            this._showBtn.addChild(GlobalClass.getInstance("showBtn"));
            this._showBtn.x = 128;
            this._showBtn.y = 12;
            this._showBtn.toolTipData = Language.getString(57491);
            this._showBtn.addEventListener(flash.events.MouseEvent.CLICK, this.onShowBtnClickHandler);
            this.addChild(this._showBtn);
            this._titleTxt = ObjCreate.createTextField(Language.getString(57489), 0, 3, 140, 20, this, GlobalStyle.textFormat6);
            this._titleTxt.autoSize = flash.text.TextFieldAutoSize.CENTER;
            this._ringTxt = ObjCreate.createTextField(Language.getStringByParam(57484, 0, 0), 5, 25, 140, 20, this, GlobalStyle.textFormat1);
            this._ringTxt.autoSize = flash.text.TextFieldAutoSize.LEFT;
            ObjCreate.createTextField(Language.getString(57038), 5, 45, 140, 20, this, GlobalStyle.textFormat1);
            this._timeView = new SecTimerView();
            this._timeView.x = 70;
            this._timeView.y = 45;
            this._timeView.autoSize = flash.text.TextFieldAutoSize.LEFT;
            this._timeView.textColor = 15788607;
            this._timeView.filters = [FilterConst.glowFilter];
            this.addChild(this._timeView);
            ObjCreate.createTextField(Language.getString(57438), 5, 65, 140, 20, this, GlobalStyle.textFormat1);
            this._expTxt = ObjCreate.createTextField("0", 70, 65, 140, 20, this, GlobalStyle.textFormat6);
            ObjCreate.createTextField(Language.getString(57485), 5, 85, 140, 20, this, GlobalStyle.textFormat1);
            this._contriTxt = ObjCreate.createTextField("0", 70, 85, 140, 20, this, GlobalStyle.textFormat6);
            return;
        }

        public updateByTreeRing(arg1: SGuildTreeRing): void
        {
            if (arg1) 
            {
                this._ringTxt.htmlText = Language.getStringByParam(57484, arg1.ring, arg1.maxRing);
                this._timeView.setLeftTime(arg1.leftTime);
            }
            return;
        }

        public updateExp(arg1: int): void
        {
            this._expTxt.text = arg1.toString();
            return;
        }

        public updateContribute(arg1: int): void
        {
            this._contriTxt.text = arg1.toString();
            return;
        }

        public stageResize(): void
        {
            if (this._isShow) 
            {
                x = Global.stage.stageWidth - 165;
            }
            else 
            {
                x = Global.stage.stageWidth;
            }
            y = 180 + 20 * Global.stage.stageHeight / 1000;
            return;
        }

        public showThis(arg1: Boolean): void
        {
            var loc1=0;
            if (arg1) 
            {
                loc1 = SceneRange.display.width - 165;
                this._isShow = true;
                this._showBtn.scaleX = 1;
                this._showBtn.x = 128;
                this._showBtn.toolTipData = Language.getString(57491);
            }
            else 
            {
                loc1 = SceneRange.display.width;
                this._isShow = false;
                this._showBtn.scaleX = -1;
                this._showBtn.x = -40;
                this._showBtn.toolTipData = Language.getString(57490);
            }
            TweenMax.to(this, 0.2, {"x": loc1, "ease": Quint.easeOut});
            y = 180 + 20 * SceneRange.display.height / 1000;
            return;
        }

        /* internal  */onMouseDownHandler(arg1: Object /* flash.events.Event */): void
        {
            this.startDrag();
            return;
        }

        /* internal  */onMouseUpHandler(arg1: Object /* flash.events.Event */): void
        {
            this.stopDrag();
            return;
        }

        /* internal  */onShowBtnClickHandler(arg1: Object /* flash.events.Event */): void
        {
            this.showThis(!this._isShow);
            return;
        }

        /* internal */ /* var */_moveBtn: GButton;

        /* internal */ /* var */_titleTxt: Object /* flash.text.TextField */;

        /* internal */ /* var */_showBtn: ToolTipItem;

        /* internal */ /* var */_ringTxt: Object /* flash.text.TextField */;

        /* internal */ /* var */_timeView: SecTimerView;

        /* internal */ /* var */_expTxt: Object /* flash.text.TextField */;

        /* internal */ /* var */_contriTxt: Object /* flash.text.TextField */;

        /* internal */ /* var */_isShow: Boolean=true;
    }
